// import {useI18n} from 'vue-i18n';
// const { locale} = useI18n();
import i18n from "@/lang/i18n";



/**
 * 修改语言
 * @param lang
 */

export const changeLangUtil = (lang:any) => {
    i18n.global.locale = lang
    setLangLocalStorage(lang)
    /**
     * 没啥用 , 但是就是想要加上去
     */
    location.reload()
}

/**
 * 初始化语言
 */
export const initMyLangUtil = () => {
    let lang = localStorage.getItem("lang")
    setLangLocalStorage(lang)
}

/**
 * 将当前语言存入本地缓存中
 * @param lang 语言
 */
const setLangLocalStorage = (lang:any) => {
    if(lang == "zh" || lang == "en" || lang == "ug"){
        i18n.global.locale = lang
        localStorage.setItem("lang",lang)
    }else {
        console.log('默认')
        localStorage.setItem("lang","zh")
        i18n.global.locale = "zh"
    }
}